# sec (secundus) - simple irc client, branched from sec

include config.mk

SRC = sec.c
OBJ = ${SRC:.c=.o}

all: options sec

options:
	@echo sec build options:
	@echo "CFLAGS   = ${CFLAGS}"
	@echo "LDFLAGS  = ${LDFLAGS}"
	@echo "CC       = ${CC}"

.c.o:
	@echo CC $<
	@${CC} -c ${CFLAGS} $<

${OBJ}: config.mk

sec: ${OBJ}
	@echo CC -o $@
	@${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
	@echo cleaning
	@rm -f sec ${OBJ} sec-${VERSION}.tar.gz

dist: clean
	@echo creating dist tarball
	@mkdir -p sec-${VERSION}
	@cp -R LICENSE Makefile README config.mk ${SRC} sec-${VERSION}
	@tar -cf sec-${VERSION}.tar sec-${VERSION}
	@gzip sec-${VERSION}.tar
	@rm -rf sec-${VERSION}

install: all
	@echo installing executable file to ${DESTDIR}${PREFIX}/bin
	@mkdir -p ${DESTDIR}${PREFIX}/bin
	@cp -f sec ${DESTDIR}${PREFIX}/bin
	@chmod 755 ${DESTDIR}${PREFIX}/bin/sec
	@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
	@mkdir -p ${DESTDIR}${MANPREFIX}/man1
#	@sed "s/VERSION/${VERSION}/g" < sec.1 > ${DESTDIR}${MANPREFIX}/man1/sec.1
#	@chmod 644 ${DESTDIR}${MANPREFIX}/man1/sec.1

uninstall:
	@echo removing executable file from ${DESTDIR}${PREFIX}/bin
	@rm -f ${DESTDIR}${PREFIX}/bin/sec
	@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
	@rm -f ${DESTDIR}${MANPREFIX}/man1/sec.1

.PHONY: all options clean dist install uninstall
